package com.miaosha.validator;

import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

public class ValidationResult {
    // 校验是否有错
    private boolean hasError = false;

    //存放错误信息
    private Map<String, String> errorMap = new HashMap<>();

    public boolean isHasError() {
        return hasError;
    }

    public void setHasError(boolean hasError) {
        this.hasError = hasError;
    }

    public Map<String, String> getErrorMap() {
        return errorMap;
    }

    public void setErrorMap(Map<String, String> errorMap) {
        this.errorMap = errorMap;
    }

    // 实现通用格式化获取message
    public String getErrorMessage(){
       return StringUtils.join(errorMap.values().toArray(), ",");
    }
}
